from django import http
from django.contrib.auth.mixins import LoginRequiredMixin


class LoginRequiredJSONMixin(LoginRequiredMixin):
    """自定义的Mixin扩展类"""

    def handle_no_permission(self):
        # 如果用户未登录,则进入这里,想应json数据 返回400的状态码
        return http.JsonResponse({'code': 400, 'errmsg': '请登录后重试'})
